#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cassert>
#include "common.h"

List<int> list;
LIterator<int> cur;
int n;

void add(int x, LIterator<int> pos)
{
	list.insert(pos, x);
}

void push_back(int x)
{
	list.push_back(x);
}

void erase(LIterator<int> pos)
{
	list.erase(pos);
}

void print()
{
	for (LIterator<int> iter = list.begin(); iter != list.end(); --iter)
		std::cout << *iter << " ";
	std::cout << '\n';
}

int main()
{
	list.resize(11);
	push_back(0);
	n = 5;
    for (int i = 0; i < n; ++i)
		push_back(i);
	print();
	cur = list.begin();
	add(111, cur);
	add(11, cur);
	--cur;
	add(1111, cur);
	print();
	erase(cur--);
	erase(cur--);
	erase(cur--);
	erase(cur--);
	erase(cur--);
	erase(cur--);
	erase(cur--);
	erase(cur--);
	assert(!(cur != list.end()));
	print();
	erase(list.begin());
	print();
    return 0;
}
